<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>在线用户</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/static/bui/css/bs3/dpl.css" rel="stylesheet" type="text/css"/>
    <link href="/static/bui/css/bs3/bui.css" rel="stylesheet" type="text/css"/>

</head>

<body>
<div class="content" style="margin: 15px">

    <input type="hidden" name="roleId" value="${id}">

    <div class="offset3">
        <div id="t1">

        </div>
        <br>

        <div id="tbar"></div>
    </div>


    <script src="http://g.tbcdn.cn/fi/bui/jquery-1.8.1.min.js"></script>
    <script src="http://g.alicdn.com/bui/bui/1.1.10/bui-min.js"></script>
    <script type="text/javascript">
        BUI.use(['bui/tree', 'bui/toolbar', 'bui/editor'], function (Tree, Toolbar, Editor) {
            var data =${data};
            var tree = new Tree.TreeList({
                render: '#t1',
                checkType: 'all',
                root: {
                    id: '0',
                    text: 'ROOT',
                    expanded: true
                },
                showRoot: true,
                nodes: data,
                showLine: true //显示连接线
            });
            tree.render();
            var bar = new Toolbar.Bar({
                render: '#tbar',
                elCls: 'button-group',
                children: [
                    {
                        elCls: 'button button-small',
                        content: '提交',
                        handler: function () {
                            var checkedNodes = tree.getCheckedNodes();
                            var str = '';
                            BUI.each(checkedNodes, function (node) {
                                str += node.id + ',';
                            });

                            var data = {
                                ids: str,
                                id: $("input[name='roleId']").val()
                            }
                            $.ajax({
                                url: '/role/bind/menu.json',
                                dataType: 'json',
                                type: "POST",
                                data: data,
                                success: function (data) {
                                    if (data.code == 2000) {
                                        BUI.Message.Alert("成功")
                                    } else {
                                        BUI.Message.Alert("失败")
                                    }
                                }
                            })
                        }
                    }
                ]
            });
            bar.render();


        })
        ;
    </script>

    <!-- script end -->
</div>
</body>
</html>
